package com.atguigu.tingshu.search.api;

import com.atguigu.tingshu.common.anno.GuiGuLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.search.service.ItemService;
import com.atguigu.tingshu.search.service.SearchService;
import com.atguigu.tingshu.vo.album.AlbumInfoDetailVo;
import com.atguigu.tingshu.vo.search.AlbumInfoIndexSearchVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "专辑详情管理")
@RestController
@RequestMapping("api/search/albumInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class itemApiController {

	private final ItemService itemService;

	private final SearchService searchService;

	@Autowired
	public itemApiController(ItemService itemService, SearchService searchService) {
		this.itemService = itemService;
		this.searchService = searchService;
	}
	/**
	 * @description: 根据一级分类id查询专辑数据
	 * @author Petrichor
	 * @date 2023/12/27 22:45
	 * @param category1Id  一级分类id
	 * @return List<AlbumInfoIndexSearchVo> 专辑数据集合
	**/
	@Operation(summary = "获取频道页数据")
	@GetMapping("/channel/{category1Id}")
	public Result<List<AlbumInfoIndexSearchVo>> channel(@PathVariable Long category1Id) {
		List<AlbumInfoIndexSearchVo> albumInfoIndexSearchVoList = searchService.channel(category1Id) ;
		return Result.ok(albumInfoIndexSearchVoList) ;
	}
	/**
	 * @description: 根据专辑id查询专辑详情
	 * @author Petrichor
	 * @date 2024/1/1 13:55
	 * @param albumId 专辑id
	 * @return AlbumInfoDetailVo 专辑详情数据
	**/
	@GuiGuLogin(required = false)			// 不需要进行登录
	@Operation(summary = "专辑详情")
	@GetMapping("/{albumId}")
	public Result<AlbumInfoDetailVo> findAlbumInfoDetail(@PathVariable Long albumId){
		AlbumInfoDetailVo albumInfoDetailVo = this.itemService.findAlbumInfoDetail(albumId);
		return Result.ok(albumInfoDetailVo);
	}
}

